import Mock from 'mockjs'

// function strSpt(url) {
//   let arr = url.split('?')
//   console.log(arr, 'arr')
//   return arr[1].split('/')
// }

Mock.mock('/goods/aside', 'get', {
  asideList: [
    {
      title: '商品管理',
      children: [
        { title: '商品列表', path: '/goods/goodsList' },
        { title: '添加商品', path: '/goods/addGoods/select' },
        { title: '商品审核', path: '/goods/goodsCheck' },
        { title: '商品回收站', path: '/goods/goodsTrash' },
        { title: '商品评价', path: '/goods/goodsComment' }
      ]
    },
    {
      title: '商品配置',
      children: [
        { title: '商品分类', path: '/goods/goodsSort/fist' },
        { title: '规格参数', path: '/goods/goodsParams' },
        { title: '品牌管理', path: '/goods/brandAdmin' },
        { title: '图片库管理', path: '/goods/imgAdmin' }
      ]
    }
  ],
  status: 200
})

Mock.mock('/runs/aside', 'get', {
  asideList: [
    {
      title: '秒杀专区',
      children: [
        { title: '秒杀活动列表', path: '/runs/miaoSha' },
        { title: '秒杀时间段列表', path: '/runs/timeList' },
        { title: '设置商品', path: '/runs/setShop' },
        { title: '商品列表', path: '/runs/shopList' },
        { title: '提醒通知', path: '/runs/remain' },
        { title: '通知日志', path: '/runs/notification' }
      ]
    },
    {
      title: '广告管理',
      children: [
        { title: '广告列表', path: '/runs/advetList' },
        { title: '添加广告', path: '/runs/addAdvet' }
      ]
    }
  ],
  status: 200
})

Mock.mock('/goods/goodsList', 'get', {
  body: {
    'goodsState|4': [
      {
        title: '@CNAME',
        'id|+1': 100,
        'number|100-2000': 100
      }
    ],
    goodsList: []
  },
  status: 200
})

Mock.mock(/^\/goods\/pageFindGoods/, 'post', function(res) {
  return Mock.mock({
    flag: true,
    code: 200,
    total: 1000,
    'data|20': [
      {
        id: '@ID',
        name: '服装',
        parentId: 1,
        'goodsNum|100-1000': 100,
        isShow: 1,
        isMenu: 1,
        seq: 1
      }
    ]
  })
})

Mock.mock(/^\/goods\/delete/, 'get', function(res) {
  return Mock.mock({
    flag: true,
    code: 200
  })
})

Mock.mock(/^\/goods\/chakanxiaji/, 'get', function(res) {
  return Mock.mock({
    flag: true,
    code: 200,
    total: 1000,
    message: '下级获取成功',
    'data|20': [
      {
        id: '@ID',
        name: '@CNAME', // 分类名称
        'goodsNum|1000-2000': 1, // 商品数量
        parentId: 2,
        isMenu: 1, // 是否导航
        isShow: 1, // 是否显示
        seq: 1 // 排序
      }
    ]
  })
})

Mock.mock('/goods/getAddress', 'get', {
  code: 200,
  'data|3': [
    {
      parentId: '@ID',
      name: '@cname'
    }
  ]
})

Mock.mock('/goods/template', 'get', {
  code: 200,
  'data|3': [
    {
      templateId: '@ID',
      name: '@cname'
    }
  ]
})

Mock.mock('/goods/add', 'post', {
  code: 200
})
